#ifndef GENIE_SWITCHES
#define GENIE_SWITCHES

#include "common.h"
#include "nvm.h"

#define SWITCHES_COUNT  ( 1 << 2 )
/*
wKeys.bit.no0 = u8GetStatus2B();	  //2B-KEYSWITCH
wKeys.bit.no1 = u8GetStatus10C();	   //10C-LEFT_STEER_TURN_LIMIT
wKeys.bit.no2 = 0;	   
wKeys.bit.no3 = 0;
wKeys.bit.no4 = u8GetStatus1A();	  //1A-1A/INPUT
wKeys.bit.no5 = u8GetStatus11B();	   //11B-UP_LIMIT
wKeys.bit.no6 = u8GetStatus12C();	   //12C-DOWN_LIMIT
wKeys.bit.no7 = u8GetStatus10A();	   //10A-=FREEWHEEL
wKeys.bit.no8 = u8GetStatus12B();	   //12B-CHASSIS_UP
wKeys.bit.no9 = u8GetStatus11C();	   //11C-TILT_SENSOR
wKeys.bit.no10 = 0;
wKeys.bit.no11 = u8GetStatus10B();	   //10B-POTHOLE_LIMIT
wKeys.bit.no12 = u8GetStatus12A();	   //12A-CHASSIS_DN
wKeys.bit.no13 = 0;
wKeys.bit.no14 = u8GetStatus5B();	  //5B-MOTOR_FAULT_1
wKeys.bit.no15 = u8GetStatus5C();	  //5C-MOTOR_FAULT_2
*/
struct switches
{
   UINT8  index;
   UINT16 awSwitches[ SWITCHES_COUNT];

   union
   {
      UINT16 word;
      struct
      {
         UINT16 b0: 1;
         UINT16 b1: 1;
         UINT16 b2: 1;
         UINT16 b3: 1;
         UINT16 b4: 1;
         UINT16 b5: 1;
         UINT16 b6: 1;
         UINT16 b7: 1;
         UINT16 b8: 1;
         UINT16 b9: 1;
         UINT16 b10: 1;
         UINT16 b11: 1;
         UINT16 b12: 1;
         UINT16 b13: 1;
         UINT16 b14: 1;
         UINT16 b15: 1;
      } sw;
	  struct
      {
         UINT16 f2B: 1;
         UINT16 f10C: 1;
         UINT16 b2: 1;
         UINT16 b3: 1;
         UINT16 f1A: 1;
         UINT16 f11B: 1;
         UINT16 f12C: 1;
         UINT16 f10A: 1;
         UINT16 f12B: 1;
         UINT16 f11C: 1;
         UINT16 b10: 1;
         UINT16 f10B: 1;
         UINT16 f12A: 1;
         UINT16 b13: 1;
         UINT16 f5B: 1;
         UINT16 f5C: 1;
      } sw2;
   } wSwitches, wSwitchesOn, wSwitchesOff;

};
// Connector Pin
//-------------------
#define DUAL_OUTDOOR_SWITCH     u8GetStatusJ34()                  // 2-4


#define KEY_SWITCH       SWITCH_Data.wSwitches.sw.b0        // J1-2B
#define LEFT_BRAKE       SWITCH_Data.wSwitches.sw.b1        // J1-10C
//#define BRAKE_ON         SWITCH_Data.wSwitches.sw.b1        // J1-10C
//#define LEFT_TURN_LIMIT  SWITCH_Data.wSwitches.sw.b1        // J1-10C
#define PMODE            SWITCH_Data.wSwitches.sw.b2        // internal
#define UNUSED           SWITCH_Data.wSwitches.sw.b3        // internal
#define FOOT_PLATE       SWITCH_Data.wSwitches.sw.b4        // J1-1A
#define OUTDOOR_SWITCH   SWITCH_Data.wSwitches.sw.b5        // J1-11B
#define CRASH_LIMIT      SWITCH_Data.wSwitches.sw.b6        // J1-12C
#define RIGHT_BRAKE      SWITCH_Data.wSwitches.sw.b7        // J1-10A
//#define OVERLOAD         SWITCH_Data.wSwitches.sw.b7
//#define FREEWHEEL_SW     SWITCH_Data.wSwitches.sw.b7
#define CHASSIS_UP_SW    SWITCH_Data.wSwitches.sw.b8        // J1-12B
//#define LAST_LEVEL_SENSOR     SWITCH_Data.wSwitches.sw.b9
#define LEVEL_SENSOR     SWITCH_Data.wSwitches.sw.b9        // J1-11C
//#define KEY_SWITCH       SWITCH_Data.wSwitches.sw.b10     // pressure sensor 2
#define POTHOLE_LIMIT    SWITCH_Data.wSwitches.sw.b11       // J1-10B
#define CHASSIS_DOWN_SW  SWITCH_Data.wSwitches.sw.b12       // J1-12A
//#define LEVEL_SENSOR     SWITCH_Data.wSwitches.sw.b13     // battery voltage
//SWITCH_Data.wSwitches.sw.b14     // solenoid current
//SWITCH_Data.wSwitches.sw.b15     // pressure sensor 1
#define OUTDOOR_LIMIT     u8GetStatusJ33()                  // 2-3

#define SCAN_ON_KEY_SWITCH        SWITCH_Data.wSwitchesOn.sw.b0
#define SCAN_ON_SPARE_1         SWITCH_Data.wSwitchesOn.sw.b1
#define SCAN_ON_PMODE           SWITCH_Data.wSwitchesOn.sw.b2
#define SCAN_ON_UNUSED          SWITCH_Data.wSwitchesOn.sw.b3
#define SCAN_ON_BATTERY_FAULTED  SWITCH_Data.wSwitchesOn.sw.b4
#define SCAN_ON_OUTDOOR_SWITCH  SWITCH_Data.wSwitchesOn.sw.b5
#define SCAN_ON_DOWN_LIMIT      SWITCH_Data.wSwitchesOn.sw.b6
//#define SCAN_ON_OVERLOAD        SWITCH_Data.wSwitchesOn.sw.b7
//#define SCAN_ON_FREEWHEEL_SW    SWITCH_Data.wSwitchesOn.sw.b7
#define SCAN_ON_CHASSIS_UP_SW   SWITCH_Data.wSwitchesOn.sw.b8
//#define SCAN_ON_LAST_LEVEL_SENSOR    SWITCH_Data.wSwitchesOn.sw.b9
#define SCAN_ON_LEVEL_SENSOR    SWITCH_Data.wSwitchesOn.sw.b9
//#define SCAN_ON_KEY_SWITCH      SWITCH_Data.wSwitchesOn.sw.b10
#define SCAN_ON_POTHOLE_LIMIT   SWITCH_Data.wSwitchesOn.sw.b11
#define SCAN_ON_CHASSIS_DOWN_SW SWITCH_Data.wSwitchesOn.sw.b12
//#define SCAN_ON_LEVEL_SENSOR    SWITCH_Data.wSwitchesOn.sw.b13

#define SCAN_OFF_KEY_SWITCH        SWITCH_Data.wSwitchesOff.sw.b0
#define SCAN_OFF_SPARE_1         SWITCH_Data.wSwitchesOff.sw.b1
#define SCAN_OFF_PMODE           SWITCH_Data.wSwitchesOff.sw.b2
#define SCAN_OFF_UNUSED          SWITCH_Data.wSwitchesOff.sw.b3
#define SCAN_OFF_BATTERY_FAULTED  SWITCH_Data.wSwitchesOff.sw.b4
#define SCAN_OFF_OUTDOOR_SWITCH  SWITCH_Data.wSwitchesOff.sw.b5
#define SCAN_OFF_DOWN_LIMIT      SWITCH_Data.wSwitchesOff.sw.b6
//#define SCAN_OFF_OVERLOAD        SWITCH_Data.wSwitchesOff.sw.b7
//#define SCAN_OFF_FREEWHEEL_SW    SWITCH_Data.wSwitchesOff.sw.b7
#define SCAN_OFF_CHASSIS_UP_SW   SWITCH_Data.wSwitchesOff.sw.b8
#define SCAN_OFF_LEVEL_SENSOR    SWITCH_Data.wSwitchesOff.sw.b9
//#define SCAN_OFF_LAST_LEVEL_SENSOR    SWITCH_Data.wSwitchesOff.sw.b9
//#define SCAN_OFF_KEY_SWITCH      SWITCH_Data.wSwitchesOff.sw.b10
#define SCAN_OFF_POTHOLE_LIMIT   SWITCH_Data.wSwitchesOff.sw.b11
#define SCAN_OFF_CHASSIS_DOWN_SW SWITCH_Data.wSwitchesOff.sw.b12
//#define SCAN_OFF_LEVEL_SENSOR    SWITCH_Data.wSwitchesOff.sw.b13


extern struct switches SWITCH_Data;
extern void switches(void);


#endif // GENIE_SWITCHES
